<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui" > 

	<h:form id="frm2">	
		<p:growl id="msgs2" showDetail="true" />
		<p:panel id="prodPanel" header="【第二步】订单采购信息录入" style="margin-bottom:5px">
     
			<h:panelGrid id="detailGrid" columns="10" cellspacing="10" >					
		        <p:commandButton id="purchBtn" value="选择合同采购清单物料..." type="button" 
		        	icon="fa fa-fw fa-search-plus" onclick="PF('ovpl').loadContents();" />		
				<p:commandButton value="生成订单金额" icon="ui-icon-plus" 
	           		process="@this" update=":frm1:pOrderAmount :frm2:msgs2"
                 	actionListener="#{purchMB.genOrderAmount()}"  >					
				</p:commandButton>
			</h:panelGrid>
			<!-- 选择采购清单 -->
		    <p:overlayPanel id="purchBtnPanel" for="purchBtn" hideEffect="fade" dynamic="true" 
		   				showCloseIcon="false" style="width:900px"  widgetVar="ovpl"  >
		        <p:dataTable var="srow" value="#{purchMB.bmeContPurches}"  
		        	paginator="true" paginatorPosition="bottom"
		         	selection="#{purchMB.selectedContPurches}" rowKey="#{srow.id}"
		         	style="margin-bottom:0"	>
		         	
		           <p:column selectionMode="multiple" style="width:16px;text-align:center"/>
		           <p:column headerText="合同名称">
		               <h:outputText value="#{srow.contName}" />
		           </p:column>
		           <p:column headerText="物料编号" filterBy="#{srow.bmeMaterial.id}" filterMatchMode="contains" >
		               <h:outputText value="#{srow.bmeMaterial.id}" />
		           </p:column>
		           <p:column headerText="物料描述" filterBy="#{srow.bmeMaterial.mdesc}" filterMatchMode="contains" >
		               <h:outputText value="#{srow.bmeMaterial.mdesc}" />
		           </p:column>
				   <p:column headerText="规格">
				       <h:outputText value="#{srow.bmeMaterial.mmodel}" />
				   </p:column>		           
		           <p:column headerText="数量">
		               <h:outputText value="#{srow.quantity}" />
		           </p:column>          
		           <p:column headerText="单价">
		               <h:outputText value="#{srow.price}" />
		           </p:column>
		            <p:column headerText="金额">
		               <h:outputText value="#{srow.amount}" />
		           </p:column>
				   <p:column headerText="加工规格">
				       <h:outputText value="#{srow.speci}" />
				   </p:column>		           
		           <p:column headerText="数量-片">
		               <h:outputText value="#{srow.processQuantity}" />
		           </p:column>			           	
		       </p:dataTable>
		        <h:panelGrid columns="3" cellspacing="10">					  
					<p:commandButton value="确认"	icon="ui-icon-check"  oncomplete="PF('ovpl').hide();" 
						action="#{purchMB.saveDetail}" update=":frm2">
					</p:commandButton>	
				</h:panelGrid>
		    </p:overlayPanel>	
		    		
			<p:dataTable id="rdt" value="#{purchMB.vod}"  var="row"  rowIndexVar="rowNum"
				resizableColumns="true" liveResize="true"  draggableColumns="true"
				scrollable="true" scrollWidth="98%" 
				editable="true"  style="margin-bottom:5px"
				paginator="true" paginatorPosition="bottom" rows="8" 
				emptyMessage="没有记录" >
				
				<f:facet name="header">订单采购信息</f:facet>
    
				<p:ajax event="rowEdit" listener="#{purchMB.onRowEdit}"
					update=":frm2:msgs2" />
				<p:ajax event="rowEditCancel"	listener="#{purchMB.onRowCancel}"
					update=":frm2:msgs2" />				
				
				<p:column headerText="修改" style="width:32px">
					<p:rowEditor editTitle="修改" cancelTitle="取消" saveTitle="保存"/>
				</p:column>
				<p:column headerText="删除" style="width:32px">
					<p:commandButton icon="ui-icon-minus"   title="删除"  immediate="true"
						action="#{purchMB.delDetail}" update=":frm2">
						<f:setPropertyActionListener value="#{row}"
							target="#{purchMB.selectedd}" />
						<p:confirm header="确认" message="你确定删除此记录信息？" icon="ui-icon-alert" />
					</p:commandButton>	
				</p:column>					
				<p:column headerText="No." width="20" >
					#{rowNum+1}
				</p:column>
				<p:column headerText="物料编号" sortBy="#{row.bmeMaterial.id}" width="100" >
					<h:outputText value="#{row.bmeMaterial.id}" />
				</p:column>
				<p:column headerText="物料描述" width="100" >
					<h:outputText value="#{row.bmeMaterial.mdesc}" />
				</p:column>
				<p:column headerText="单位" width="40" >
					<h:outputText value="#{row.bmeMaterial.munit}" />
				</p:column>	
				<p:column headerText="规格" width="80" >
					<h:outputText value="#{row.bmeMaterial.mmodel}" />
				</p:column>			
				<p:column headerText="数量-片" width="100" >
					<p:cellEditor>
						<f:facet name="output">	<h:outputText value="#{row.processQuantity}" /></f:facet>
						<f:facet name="input">	<p:inputText value="#{row.processQuantity}" /></f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="数量" width="100" >
					<p:cellEditor>
						<f:facet name="output"><h:outputText value="#{row.mquantity}" /></f:facet>
						<f:facet name="input"><p:inputText value="#{row.mquantity}"  /></f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="单价" width="100" >
					<p:cellEditor>
						<f:facet name="output"><h:outputText value="#{row.mprice}" /></f:facet>
						<f:facet name="input"><p:inputText value="#{row.mprice}" /></f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="金额" width="100" >
					<p:cellEditor>
						<f:facet name="output"><h:outputText value="#{row.mamount}" /></f:facet>
						<f:facet name="input"><p:inputText value="#{row.mamount}" />
						</f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="运费单价" width="100" >
					<p:cellEditor>
						<f:facet name="output"><h:outputText value="#{row.tprice}" /></f:facet>
						<f:facet name="input"><p:inputText value="#{row.tprice}" /></f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="运费总价" width="100" >
					<p:cellEditor>
						<f:facet name="output"><h:outputText value="#{row.tamount}" /></f:facet>
						<f:facet name="input"><p:inputText value="#{row.tamount}" />
						</f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="总金额" width="100" >
					<p:cellEditor>
						<f:facet name="output">	<h:outputText value="#{row.amount}" /></f:facet>
						<f:facet name="input">	<p:inputText value="#{row.amount}" /></f:facet>
					</p:cellEditor>
				</p:column>					
				
				<p:column headerText="安装区域" width="100" >
					<p:cellEditor>
						<f:facet name="output"><h:outputText value="#{row.area}" /></f:facet>
						<f:facet name="input"><p:inputText value="#{row.area}" /></f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="要求交期" width="100" >
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{row.requiredDate}" >
								<f:convertDateTime pattern="yyyy-MM-dd"  timeZone="GMT+8"/>
							</h:outputText>						
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{row.requiredDate}" >
								<f:convertDateTime pattern="yyyy-MM-dd" timeZone="GMT+8"/>
							</p:inputText>
						</f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="反馈交期" width="100" >
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{row.respDate}" >
								<f:convertDateTime pattern="yyyy-MM-dd" timeZone="GMT+8"/>
							</h:outputText>						
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{row.respDate}" >
								<f:convertDateTime pattern="yyyy-MM-dd" timeZone="GMT+8"/>
							</p:inputText>
						</f:facet>
					</p:cellEditor>
				</p:column>				
				<p:column headerText="反馈备注" width="100" >
					<p:cellEditor>
						<f:facet name="output">	<h:outputText value="#{row.respRemarks}" /></f:facet>
						<f:facet name="input">	<p:inputText value="#{row.respRemarks}" /></f:facet>
					</p:cellEditor>
				</p:column>									
				<p:column headerText="备注" width="100" >
					<p:cellEditor>
						<f:facet name="output"><h:outputText value="#{row.remarks}" /></f:facet>
						<f:facet name="input"><p:inputText value="#{row.remarks}" />
						</f:facet>
					</p:cellEditor>
				</p:column>

				<p:column headerText="加工工艺" width="100" >
					<p:cellEditor>
						<f:facet name="output">	<h:outputText value="#{row.processTeck}" /></f:facet>
						<f:facet name="input">	<p:inputText value="#{row.processTeck}" /></f:facet>
					</p:cellEditor>
				</p:column>					
				<p:column headerText="加工色号" width="100" >
					<p:cellEditor>
						<f:facet name="output">	<h:outputText value="#{row.processColor}" /></f:facet>
						<f:facet name="input">	<p:inputText value="#{row.processColor}" /></f:facet>
					</p:cellEditor>
				</p:column>						
				<p:column headerText="加工单位" width="100" >
					<p:cellEditor>
						<f:facet name="output">	<h:outputText value="#{row.processUnit}" /></f:facet>
						<f:facet name="input">	<p:inputText value="#{row.processUnit}" /></f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="加工规格" width="100" >
					<p:cellEditor>
						<f:facet name="output">	<h:outputText value="#{row.processSpeci}" /></f:facet>
						<f:facet name="input">	<p:inputText value="#{row.processSpeci}" /></f:facet>
					</p:cellEditor>
				</p:column>	
				<p:column headerText="加工总量" width="100" >
					<p:cellEditor>
						<f:facet name="output">	<h:outputText value="#{row.processSum}" /></f:facet>
						<f:facet name="input">	<p:inputText value="#{row.processSum}" /></f:facet>
					</p:cellEditor>
				</p:column>					
				<p:column headerText="每片加工量" width="100" >
					<p:cellEditor>
						<f:facet name="output">	<h:outputText value="#{row.processFactor}" /></f:facet>
						<f:facet name="input">	<p:inputText value="#{row.processFactor}" /></f:facet>
					</p:cellEditor>
				</p:column>	
				<p:column headerText="加工单价" width="100" >
					<p:cellEditor>
						<f:facet name="output">	<h:outputText value="#{row.processPrice}" /></f:facet>
						<f:facet name="input">	<p:inputText value="#{row.processPrice}" /></f:facet>
					</p:cellEditor>
				</p:column>					
				<p:column headerText="加工费用" width="100" >
					<p:cellEditor>
						<f:facet name="output">	<h:outputText value="#{row.processAmount}" /></f:facet>
						<f:facet name="input">	<p:inputText value="#{row.processAmount}" /></f:facet>
					</p:cellEditor>
				</p:column>					
				
			</p:dataTable>
    
		</p:panel>
		
	</h:form>
	
		
	<!-- confirm to del detail -->
    <p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
        <p:commandButton value="确认" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
        <p:commandButton value="取消" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
    </p:confirmDialog>
				
</ui:composition>
